package com.along.utility.common.utils;

/**
 *
 * @author haojianjian
 * @date 2021-01-27 11:08:17
 *
 */
public class StringUtils {

	/**
	 * StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true
	 * StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false
	 * StringUtils.isEmpty(" bob ") = false
	 *
	 * @param s
	 *            {@code true} if the str is empty or null
	 * @author haojianjian
	 * @date 2021-01-27 11:11:34
	 */
	public static boolean isEmpty(final String str) {
		return org.apache.commons.lang3.StringUtils.isEmpty(str);
	}

	/**
	 * string (a,b,c) to string array ('a','b','c')
	 *
	 * @param str
	 * @return
	 * @author pingguanfei
	 * @date 2022-08-22 10:31:18
	 *
	 */
	public static String toStringArray(String str) {
		if (str != null && !"".equals(str)) {
			return "'" + str.replaceAll(",", "','") + "'";
		}
		return null;
	}

	/**
	 * string[] (['a','b','c']) to string array ('a','b','c')
	 *
	 * @param strArray
	 * @return
	 * @author pingguanfei
	 * @date 2022-10-20 16:01:32
	 *
	 */
	public static String toStringArray(String[] strArray) {
		if (strArray != null && strArray.length > 0) {
			return StringUtils.toStringArray(org.apache.commons.lang3.StringUtils.join(strArray, ","));
		}
		return null;
	}

}
